export default {

    namespaced: true,

    state: {
        token: ''
    },
    getters: {},
    mutations: {
        setToken(state, payload) {
            state.token = payload
        }
    },
    actions: {

        async getToken({ commit }) {

            const [err1, result] = await uni.getUserProfile({
                desc: "给用户更好的体验",
            });
            const [err2, { code }] = await uni.login();
            // console.log(code);
            // console.log(result);
            const result3 = await uni.$u.post("/users/wxlogin", { ...result, code });
            const { token } = result3.message;
            commit('setToken', token)
        }

    }
}
